<script>
  var arr = [[11, 20], 30, [40, 50, [60, 70, [80, 92, [110, 911]]]]];
  function flatFn1(arr) {
    return arr.flat(Infinity);
  }

  // console.log(flatFn1(arr));

  function flatFn2(arr) {
    arr = arr.toString().split(",");
    console.log(arr)
    let newArr = arr.map((item) => {
      item = +item;
      return item;
    });

    return newArr;
  }

  console.log(flatFn2(arr));

  function flatFn3(arr) {
    let str = JSON.stringify(arr);
    console.log(typeof str);
    str = str.replace(/(\[|\])/g, "");
    str = "[" + str + "]";
    return JSON.parse(str);
  }

  console.log(flatFn3(arr));

  function flatFn4(arr) {
    return arr.reduce((opt1, opt2) => {
      return opt1.concat(Array.isArray(opt2) ? flatFn4(opt2) : opt2);
    }, []);
  }

  console.log(flatFn4(arr));
</script>
